﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyCommerce.Business.Stores;

namespace MyCommerce.Presentation.Stores.Presenters
{
    public class ProductStockPresenter
    {
        private IViews.IProductStock vManagedView;

        public ProductStockPresenter(IViews.IProductStock managedView)
        {
            if (managedView == null)
            {
                throw new Exception("managedView cannot be null");
            }

            vManagedView = managedView;
            vManagedView.OnLoad += new EventHandler(vManagedView_OnLoad);
            vManagedView.OnEdit += new IViews.OnEntityEventHandler(vManagedView_OnEdit);
            vManagedView.OnDelete += new IViews.OnEntityEventHandler(vManagedView_OnDelete);
            vManagedView.OnSave += new IViews.OnSaveEventHandler(vManagedView_OnSave);

        }

        void vManagedView_OnSave(object sender, bool isNew)
        {
            //ConveyorManager vConveyorManager = new ConveyorManager();
            //if (isNew)
            //{
            //    vConveyorManager.SaveConveyor(vManagedView.objConveyor);
            //}
            //else
            //{
            //    vConveyorManager.UpdateConveyor(vManagedView.objConveyor);
            //}
            //vManagedView.colConveyor = vConveyorManager.GetConveyors();
        }

        void vManagedView_OnDelete(object sender, long id)
        {
            //ConveyorManager vConveyorManager = new ConveyorManager();
            //vConveyorManager.DeleteConveyor(id);
            //vManagedView.colConveyor = vConveyorManager.GetConveyors();
        }

        void vManagedView_OnEdit(object sender, long id)
        {
            //ConveyorManager vConveyorManager = new ConveyorManager();
            //vManagedView.objConveyor = vConveyorManager.GetConveyorByID(id);
        }

        void vManagedView_OnLoad(object sender, EventArgs e)
        {
            ProductManager vProductManager = new ProductManager();
            vManagedView.colProduct = vProductManager.GetProducts();

            SupplierManager vSupplierManager = new SupplierManager();
            vManagedView.colSupplier = vSupplierManager.GetSuppliers();

            StoreManager vStoreManager = new StoreManager();
            vManagedView.colStore = vStoreManager.GetStoresActives();

            ProductPriceManager vProductPriceManager = new ProductPriceManager();
            vManagedView.colProductPrice = vProductPriceManager.GetProductPrices();
        }

    }
}
